package com.hm.cdz;

import com.hm.common.util.StringUtil;

/**
 * @author shishun.wang
 * @date 2018年5月4日 上午11:39:09
 * @version 1.0
 * @describe
 */
public enum DeviceCallBackErrorEnum {

	ActSucceded("ActSucceded", "命令可以执行"),

	ChargeIdErr("ChargeIdErr", "桩ID错误"),

	ChargeSessionErr("ChargeSessionErr", "sessionid错误"),

	ChargePortErr("ChargePortErr", "充电口错误"),

	ChargeSignErr("ChargeSignErr", "命令签名数据错误"),

	ChargerNotIdle("ChargerNotIdle", "充电设备没处于空闲状态"),

	ChargerHaveRunned("ChargerHaveRunned", "充电设备正运行充电"),

	ChargerNotRunned("ChargerNotRunned", "充电设备没处于运行状态"),

	HaveGotSameCmd("HaveGotSameCmd", "已经收到相同的命令"),

	DeviceFaulted("DeviceFaulted", "系统处于故障状态"),

	OnOffReturnCmdMax("OnOffReturnCmdMax", "未知还要问厂家");

	private DeviceCallBackErrorEnum(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private String code;

	private String desc;

	public String code() {
		return code;
	}

	public String desc() {
		return desc;
	}

	public DeviceCallBackErrorEnum conversion(String code) {
		if (StringUtil.isBlankOrNull(code)) {
			return null;
		}
		for (DeviceCallBackErrorEnum item : DeviceCallBackErrorEnum.values()) {
			if (item.code().equals(code)) {
				return item;
			}
		}
		return null;
	}

}
